package image;

import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.glu.GLU;

public class GLErrors
	{
	public static boolean check(GL gl, String message) 
		{
		if(!gl.getContext().isCurrent()) 
			{
			System.err.println("Error: Cannot check for errors when context is not current: "+message);
			new Throwable().printStackTrace();
			return true;
			}
		else 
			{
			int error = gl.glGetError();
			if(error!=GL2.GL_NO_ERROR) 
				{
				System.err.println(message+": "+new GLU().gluErrorString(error));
				new Throwable().printStackTrace();
				return true;
				}
			}
		return false;
		}
	}
